<!-- 新增异常处理页面 -->
<template>
  <div class="supplierMessage">
    <!-- 出库单号搜索 -->
    <el-card class="searchCard" shadow="never" :body-style="{ padding: '20px' }">
      <div slot="header">
        <span>出库单号搜索</span>
      </div>
      <el-form ref="searchForm" class="searchForm" :model="searchForm" label-width="130px" :inline="false" size="normal">
        <el-form-item label="出库单号：">
          <el-input v-model="searchForm.warehouseName" style="width:200px" placeholder="输入完整的出库单号" size="small" clearable />
        </el-form-item>
        <!-- 查询按钮 -->
        <el-form-item>
          <el-button type="primary" size="small">查询</el-button>
        </el-form-item>
      </el-form>
      <!-- 出库单号和关联销售单号 -->
      <div style="display:flex;justify-content:space-between;margin:10px 50px;font-size:14px;">
        <div>出库单号：CK20210120150603223</div>
        <div>关联销售单号：CK20210120150603223</div>
      </div>
      <!-- 客户和供应方 -->
      <div style="display:flex;justify-content:space-between;margin:10px 50px;font-size:14px;">
        <div>客户：刘文 17312341234 </div>
        <div>供应方：浙江微红健康有限公司</div>
      </div>

      <template>
        <!-- 异常处理列表 -->
        <el-table
          :data="tableData"
          style="width: 100%"
          border
          :header-cell-style="{textAlign: 'center'}"
          :cell-style="{ textAlign: 'center' }"
        >
          <el-table-column
            prop="num"
            label="商品名称"
            width="200"
          />
          <el-table-column
            prop="warehouseName"
            label="商品类型"
            width="200"
          />
          <el-table-column
            prop="staff"
            label="出库数量"
            width="200"
          />
          <el-table-column
            prop="telephone"
            label="出库方式"
          />
          <el-table-column
            prop="contactPlace"
            label="批次"
          />
          <el-table-column
            prop="remarks"
            label="供应方联系人"
          />
          <el-table-column
            label="操作"
            width="400"
          >
            <!-- 按钮 -->
            <template>
              <el-button type="text" size="small" @click="chargeback">处理</el-button>
              <el-button type="text" size="small" @click="chargeback">历史</el-button>
            </template>
          </el-table-column>
        </el-table>

        <div class="block">
          <!-- 消息表格分页器 -->
          <el-pagination
            :current-page="currentPage4"
            :page-sizes="[100, 200, 300, 400]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="400"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </template>
    </el-card>

    <!-- 选中出库展示出库信息弹框 -->
    <el-dialog
      title="出库信息"
      center
      :visible.sync="isChargeback"
      width="30%"
    >
      <!-- 出库信息弹框表单 -->
      <el-form ref="form" :model="outWarehouseForm" label-width="100px" :inline="false" size="normal">
        <!-- 销售单号 -->
        <el-form-item label="销售单号：">
          XS20190922151603223
        </el-form-item>
        <!-- 商品名称 -->
        <el-form-item label="商品名称：">
          面膜
        </el-form-item>

        <!-- 商品类型 -->
        <el-form-item label="商品类型：">
          实物
        </el-form-item>

        <!-- 出库方式 -->
        <el-form-item label="出库方式：">
          <el-select v-model="outWarehouseForm.deliveryMethod" placeholder="请选择出库方式" size="mini" @change="selectOutWarehouse">
            <el-option label="供应商直发" value="0" />
            <el-option label="仓库发货" value="1" />
            <el-option label="自提" value="2" />
          </el-select>
        </el-form-item>

        <!-- 选择供应直发出库方式显示副内容 -->
        <div v-show="isSupplier" style="margin:0 auto;width:80%;height:100%;background-color:#d7d7d7;">
          <!-- 快递单号 -->
          <el-form-item label="快递单：">
            <el-input placeholder="输入快递单号（选填）" style="width:80%" size="mini" clearable />
          </el-form-item>
          <!-- 供应方选择 -->
          <el-form-item label="供应方：">
            <el-input placeholder="商品指定供应方公司名称" style="width:80%" size="mini" clearable @focus="chooseSupplier" />
          </el-form-item>
        </div>

        <!-- 选择仓库发货方式显示副内容 -->
        <div v-show="isWarehouse " style="margin:0 auto;width:80%;height:100%;background-color:#d7d7d7;">
          <!-- 快递单号 -->
          <el-form-item label="快递单：">
            <el-input placeholder="输入快递单号（选填）" style="width:80%" size="mini" clearable />
          </el-form-item>

          <!-- 出库仓库选择 -->
          <el-form-item label="出库仓库：">
            <el-select placeholder="仓库名称">
              <el-option label="仓库1" value="shanghai" />
              <el-option label="仓库2" value="beijing" />
            </el-select>
          </el-form-item>

          <!-- 批次选择 -->
          <el-form-item label="批次：">
            <el-select placeholder="批次">
              <el-option label="批次1" value="shanghai" />
              <el-option label="批次2" value="beijing" />
            </el-select>
          </el-form-item>

          <!-- 是否售后选择 -->
          <el-form-item label="是否售后：">
            <el-radio-group>
              <el-radio label="是" />
              <el-radio label="否" />
            </el-radio-group>
          </el-form-item>
        </div>

        <!-- 选择自提发货方式显示副内容 -->
        <div v-show="isSelf " style="margin:0 auto;width:80%;height:100%;background-color:#d7d7d7;">
          <!-- 出库仓库选择 -->
          <el-form-item label="出库仓库：">
            <el-select size="mini" placeholder="仓库名称">
              <el-option label="仓库1" value="shanghai" />
              <el-option label="仓库2" value="beijing" />
            </el-select>
          </el-form-item>
          <!-- 批次选择 -->
          <el-form-item label="批次：">
            <el-select size="mini" placeholder="批次">
              <el-option label="批次1" value="shanghai" />
              <el-option label="批次2" value="beijing" />
            </el-select>
          </el-form-item>

          <!-- 是否售后选择 -->
          <el-form-item label="是否售后：">
            <el-radio-group>
              <el-radio label="是" />
              <el-radio label="否" />
            </el-radio-group>
          </el-form-item>
        </div>

        <!-- 出库数量 -->
        <el-form-item label="出库数量：">
          <el-input-number v-model="num" size="mini" :min="1" :max="10" label="出库数量" /> 盒
          <div>剩余总数：10</div>
        </el-form-item>
      </el-form>

      <!-- 按钮 -->
      <span slot="footer">
        <el-button type="primary" @click="submit">提交</el-button>
        <el-button type="default">取消</el-button>
      </span>
    </el-dialog>

    <!-- 退单弹框 -->
    <el-dialog
      title="退单"
      center
      :visible.sync="Chargeback"
      width="30%"
    >
      <!-- 退单表单 -->
      <el-form ref="form" label-width="100px" :inline="false" size="normal">
        <!-- 商品名称 -->
        <el-form-item label="商品名称：">
          水笔
        </el-form-item>
        <!-- 退单数量 -->
        <el-form-item label="退单数量：">
          <el-input-number size="mini" :min="1" :max="10" label="退单数量" placeholder="退单数量" />
        </el-form-item>
        <!-- 退单原因 -->
        <el-form-item label="退单原因：">
          <el-input placeholder="15字以内" maxlength="15" show-word-limit size="mini" type="textarea" clearable />
        </el-form-item>
        <!-- 退单合计 -->
        <el-form-item label="退单合计：">
          9.89元
        </el-form-item>
        <!-- 最终结算 -->
        <el-form-item label="最终结算：">
          <el-input placeholder="最终结算" size="mini" style="width:200px" clearable />元
        </el-form-item>
        <!-- 已付 -->
        <el-form-item label="已付：">
          <el-input placeholder="已支付" size="mini" style="width:200px" clearable />元
          <div>未付金额 <span style="color:red">0.09</span>元</div>
        </el-form-item>
      </el-form>

      <span slot="footer">
        <el-button type="primary">确认退单</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
// import引入的组件需要注入到对象中才能使用，
  components: {},
  data() {
    // 这里存放数据
    return {
      isOutWarehouseDetail: false, // 出库明细弹框
      outWarehouseForm: { // 出库信息弹框表单数据
        deliveryMethod: ''// 出库方式
      },
      isSelf: false, // 选择自提方式
      isWarehouse: false, // 仓库发货
      isSupplier: false, // 供应方直发
      // ...
      isChargeback: false, // 退单弹框
      searchForm: {
        warehouseName: '' // 仓库名称
      },
      tableData: [{
        num: 1,
        warehouseName: '服务仓',
        staff: '张三',
        telephone: '17312341234',
        contactPlace: '浙江省杭州市',
        remarks: '17311111111'
      }, {
        num: 1,
        warehouseName: '服务仓',
        staff: '张三',
        telephone: '17312341234',
        contactPlace: '浙江省杭州市',
        remarks: '17311111111'
      }],
      currentPage4: 2 // 当前页数
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {

  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {

  },
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {},
  // 方法集合
  methods: {
    submit() { // 出库信息提交
      this.isOutWarehouseDetail = true
      this.isExWarehouseMsg = false
    },
    isSold() { // 选中销售单
      this.isExWarehouseMsg = true
    },
    selectOutWarehouse() { // 选择出库方式
      console.log(this.outWarehouseForm.deliveryMethod)
      if (this.outWarehouseForm.deliveryMethod === '0') {
        this.isSupplier = true
        this.isWarehouse = false
        this.isSelf = false
      } else if (this.outWarehouseForm.deliveryMethod === '1') {
        this.isWarehouse = true
        this.isSupplier = false
        this.isSelf = false
      } else {
        this.isSelf = true
        this.isWarehouse = false
        this.isSupplier = false
      }
    },
    chargeback() { // 退单
      this.isChargeback = true
    },
    deleteWarehouse() {
      console.log('删除仓库')
    },

    handleSizeChange(val) { // 分页器事件每页条数
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) { // 分页器事件当前页
      console.log(`当前页: ${val}`)
    }
  } // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style scoped lang="scss">
.supplierMessage{
   width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #f0f2f5;
    .searchCard{
      margin: 30px;
      .searchForm{//搜索表单样式
        display: flex;
      }
    }
    .supplierList{//供应商列表
      margin: 30px;
    }
    .addWarehouse{
      display: flex;
      justify-content: space-around;
    }
    .block{//分页器样式
      margin-top: 20px;
        padding: 20px;
        display: flex;
        justify-content: center;
      }
}
</style>
